package open.witype.filetiper.fragment.menu.db;

import android.content.Context;
import android.database.Cursor;

import java.util.ArrayList;
import java.util.List;

import open.witype.filetiper.database.BaseDBAdapter;
import open.witype.filetiper.database.DBHelper;
import open.witype.filetiper.model.FavoItemBeam;

/**
 * Created by Typer on 2015/6/1 0001.
 *
 */
public class FavoDBAdapter extends BaseDBAdapter {

    public static FavoDBAdapter favoDBAdapter;

    public FavoDBAdapter(Context context) {
        super(context);
    }

    public static FavoDBAdapter getInstance(Context context){
        if (favoDBAdapter == null)
            return new FavoDBAdapter(context);
        return favoDBAdapter;
    }

    public List<FavoItemBeam> getFavoList(){
        List<FavoItemBeam> lists = null;
        if (database == null)
            return lists;
        Cursor cur = database.query(true, DBHelper.FAVO_TABLE,null,null,null,null,null,null,null);
        lists = new ArrayList<>();
        while (cur.moveToNext()){
            FavoItemBeam itemBeam = new FavoItemBeam();
            itemBeam.setId(cur.getString(0));
            itemBeam.setPath(cur.getString(1));
            itemBeam.setRemark(cur.getString(2));
            itemBeam.setIndex(cur.getString(3));
            itemBeam.setShow(cur.getString(4));
            lists.add(itemBeam);
        }
        cur.close();
        return lists;
    }
}
